package com.pan.admin.generator.entity;

import com.pan.admin.generator.constant.ApiGenApiChannelDataExchangeRespFieldEnum;
import com.pan.admin.generator.constant.ApiGenFieldEnum;
import com.pan.admin.generator.constant.ApiGenPlatParseDataExchangeFieldEnum;
import lombok.Data;

import java.util.List;

/**
 *  生成API交互模板字段
 *
 *  @author Pan
 */
@Data
public class ApiGenField {

    /** 我方字段名称 */
    private String fieldName;
    /** 我方字段中文名 */
    private String fieldChineseName;
    /** 我方字段值 */
    private String fieldValue;
    /** 对方属性转换名称 */
    private String mappingName;
    /** 对方属性值 */
    private String mappingValue;
    /** JAVA类型 */
    private String javaType;
    /** 字段注释 */
    private String fieldDoc;
    /** 表单资质映射 */
    private List<ApiGenFormField> listFormField;

    /**
     *  构建字段模板
     *
     *  @param  apiGenFieldEnum     生成基本模板字段枚举
     *  @return ApiGenField
     */
    public static ApiGenField ofTemplate(ApiGenFieldEnum apiGenFieldEnum) {
        ApiGenField apiGenField = new ApiGenField();
        apiGenField.setFieldName(apiGenFieldEnum.getFieldName());
        apiGenField.setFieldChineseName(apiGenFieldEnum.getFieldChineseName());
        return apiGenField;
    }

    /**
     *  构建解析撞库响应字段模板
     *
     *  @param  apiGenPlatParseDataExchangeFieldEnum     生成字段枚举
     *  @return ApiGenField
     */
    public static ApiGenField ofTemplate(ApiGenPlatParseDataExchangeFieldEnum apiGenPlatParseDataExchangeFieldEnum) {
        ApiGenField apiGenField = new ApiGenField();
        apiGenField.setFieldName(apiGenPlatParseDataExchangeFieldEnum.getFieldName());
        apiGenField.setFieldChineseName(apiGenPlatParseDataExchangeFieldEnum.getFieldChineseName());
        apiGenField.setJavaType(apiGenPlatParseDataExchangeFieldEnum.getJavaType());
        return apiGenField;
    }

    /**
     *  构建API渠道撞库响应字段模板
     *
     *  @param  apiGenApiChannelDataExchangeRespFieldEnum     生成字段枚举
     *  @return ApiGenField
     */
    public static ApiGenField ofTemplate(ApiGenApiChannelDataExchangeRespFieldEnum apiGenApiChannelDataExchangeRespFieldEnum) {
        ApiGenField apiGenField = new ApiGenField();
        apiGenField.setFieldName(apiGenApiChannelDataExchangeRespFieldEnum.getFieldName());
        apiGenField.setFieldChineseName(apiGenApiChannelDataExchangeRespFieldEnum.getFieldChineseName());
        apiGenField.setJavaType(apiGenApiChannelDataExchangeRespFieldEnum.getJavaType());
        return apiGenField;
    }

    /**
     *  构建自定义名称模板
     *
     *  @param  fieldName           字段名
     *  @param  fieldChineseName    字段中文名
     *  @return ApiGenField
     */
    public static ApiGenField ofCustomTemplate(String fieldName, String fieldChineseName) {
        ApiGenField apiGenField = new ApiGenField();
        apiGenField.setFieldName(fieldName);
        apiGenField.setFieldChineseName(fieldChineseName);
        return apiGenField;
    }

    /**
     *  构建自定义名称模板
     *
     *  @param  fieldName           字段名
     *  @param  fieldChineseName    字段中文名
     *  @return ApiGenField
     */
    public static ApiGenField ofCustomTemplate(String fieldName, String fieldChineseName, String javaType) {
        ApiGenField apiGenField = new ApiGenField();
        apiGenField.setFieldName(fieldName);
        apiGenField.setFieldChineseName(fieldChineseName);
        apiGenField.setJavaType(javaType);
        return apiGenField;
    }

}
